<template>
	<view class="wrap">
		<view class="taskInfoBox">
			<view class="taskInfo">
				<view>任务年度：</view>
				<view>{{ dcSupTaskInfo.taskYear }}</view>
			</view>
			<view class="taskInfo">
				<view>任务类型：</view>
				<view>{{ dcSupTaskInfo.taskTypeName }}</view>
			</view>
			<view class="taskInfo">
				<view>任务标题：</view>
				<view :class="dcSupTaskInfo.taskTitle.length > 20 ? 'bk' : ''">{{ dcSupTaskInfo.taskTitle }}</view>
			</view>
			<view class="taskInfo">
				<view>任务内容：</view>
				<view :class="dcSupTaskInfo.taskContent.length > 20 ? 'bk' : ''">{{ dcSupTaskInfo.taskContent }}</view>
				<!-- <u-input type="textarea" placeholder="无" v-model="dcSupTaskInfo.taskContent" height="100" disabled /> -->
			</view>

			<view class="taskInfo">
				<view>督办要求：</view>
				<view>{{ dcSupTaskInfo.taskRequireName }}</view>
			</view>
			<view class="taskInfo">
				<view>协同单位：</view>
				<view>{{ dcSupTaskInfo.taskCoopOrgName }}</view>
			</view>
			<view class="taskInfo">
				<view>督办人：</view>
				<view>{{ dcSupTaskInfo.taskSupUserName }}</view>
			</view>
			<view class="taskInfo">
				<view>督办科室：</view>
				<view>{{ dcSupTaskInfo.taskSupOrgName }}</view>
			</view>

			<view class="taskInfo">
				<view>牵头领导：</view>
				<view>{{ dcSupTaskInfo.taskLeaderName }}</view>
			</view>
			<view class="taskInfo">
				<view>牵头责任单位：</view>
				<view :class="dcSupTaskInfo.taskLeaderOrgName.length > 20 ? 'bk' : ''">{{ dcSupTaskInfo.taskLeaderOrgName }}</view>
			</view>
			<view class="taskInfo">
				<view>联系人：</view>
				<view>{{ dcSupTaskInfo.contactName }}</view>
			</view>
			<view class="taskInfo">
				<view>联系电话：</view>
				<view>{{ dcSupTaskInfo.contactPhone }}</view>
			</view>
			<view class="taskInfo">
				<view>督办字号：</view>
				<view>{{ dcSupTaskInfo.messageNumber }}</view>
			</view>
			<view class="taskInfo">
				<view>审核人：</view>
				<view>{{ dcSupTaskInfo.auditorName }}</view>
			</view>
			<view class="taskInfo">
				<view>反馈起始：</view>
				<view>{{ dcSupTaskInfo.taskStartTimeStr }}</view>
			</view>
			<view class="taskInfo">
				<view>反馈截止：</view>
				<view>{{ dcSupTaskInfo.taskEndTimeStr }}</view>
			</view>
			<view class="taskInfo">
				<view>反馈时间要求：</view>
				<view>{{ dcSupTaskInfo.feedbackWay }}</view>
			</view>
			<!-- 	<view class="taskInfo">
				<view>反馈附件必填：</view>
				<view>{{ dcSupTaskInfo.taskEndTime }}</view>
			</view> -->
			<!-- 附件 -->
			<view class="lh-mt-36"><LhFilelist v-if="dcSupTaskInfo.id" :bizKey="dcSupTaskInfo.id" bizType="dcSupTaskInfo_file" /></view>

			<view v-for="(item, index) in actionList" :key="index">
				<view>牵头责任单位：{{ item.leader_org_name }}</view><br>
				<view>反馈详情：{{ item.feedback_content }}</view>
				<u-button v-if="item.feedback_time=='无'" type="primary" style="margin-top: 25rpx; width: 30%; margin-bottom: 4rpx;" @click="cuiban(item.id)" :plain="true" :hairline="true" text="催办">
					催办
				</u-button>
			</view>
		</view>
	</view>
</template>
<script>
/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
import LhFilelist from '@/components/lh-filelist/lh-filelist.vue';
import tkiTree from '@/components/tki-tree/tki-tree.vue';
export default {
	components: {
		tkiTree,
		LhFilelist
	},
	data() {
		return {
			actionList: [],
			dictList: [],
			value: '',
			shadow: false,
			show: false,
			text: '',
			title: '请输入审核不通过的理由',
			label: '',
			multiple: true,
			selectParent: true,
			flod: true,
			model1: {
				auditResult: '',
				auditOption: '',
				id: '',
				targetType: '',
				targetId: '',
				dcSupTaskInfo: { id: '', createBy: '' }
			},

			model: {
				id: '',
				taskYear: new Date().getFullYear(),
				taskTypeCode: '',
				taskTypeName: '',
				taskTitle: '',
				taskContent: '',

				taskStatus: '2',
				contactName: '',
				contactPhone: '',
				formFlag: '0',
				auditFlag: '0',
				attachmentFlag: '0',
				taskStartTime: '',
				taskEndTime: '',
				taskLeader: '',
				taskLeaderName: '',
				taskLeaderOrg: '',
				taskLeaderOrgName: '',
				msgNum: '督一〔2022〕',
				msgNum2: '',
				messageNumber: '',
				remarks2: 'app',
				normalFlag: 1
			},
			dcSupTaskInfo: {},
			rules: {
				taskStartTime: [
					{
						required: true,
						message: '请选择开始时间'
					}
				],
				taskEndTime: [
					{
						required: true,
						message: '请选择时间'
					}
				],
				msgNum2: [
					{
						required: true,
						message: '请选择督办字号'
					}
				],
				taskTypeCode: [
					{
						required: true,
						message: '请选择任务类型',
						trigger: ['change', 'blur']
					}
				],
				taskTitle: [
					{
						required: true,
						message: '请输入任务标题',
						trigger: ['change', 'blur']
					}
				],
				taskContent: [
					{
						required: true,
						message: '请输入任务内容',
						trigger: ['change', 'blur']
					}
				],
				taskLeaderOrg: [
					{
						required: true,
						message: '请选择牵头责任单位',
						trigger: ['change', 'blur']
					}
				],
				testInput: [
					{
						required: true,
						message: '请输入单行文本',
						trigger: ['change', 'blur']
					}
				]
			},
			officeSelectList: [],
			userSelectList: []
		};
	},
	onLoad(params) {
		this.shadow = true;
		uni.setNavigationBarTitle({
			title: '任务详情'
		});

		this.$u.api.taskTrace.getDetailInfo(params.id).then(res => {
			this.dcSupTaskInfo = res.dcSupTaskInfo;
		});
		this.$u.api.taskTrace.getActionFeedback(params.id).then(res => {
			this.actionList = res.data;
		});

		if (params.id == undefined) {
			this.shadow = false;
		}
	},
	onReady() {},
	methods: {
		cuiban(id) {
			this.$u.api.taskTrace.cuiban(id).then(res => {
				uni.showModal({
					title: '提示',
					content: res.message,
					showCancel: false,
					success: function() {
						if (res.result == 'true') {
							uni.setStorageSync('refreshList', true);
						}
					}
				});
			});
		},
		blur() {
			this.model.taskLeaderOrg = [];
		},
		clear() {},
		treeConfirm(e) {
			e.forEach(item => {
				this.model.taskLeaderOrgName.push(item.name);
				this.model.taskLeaderOrg.push(item.id);
			});
			this.text = this.model.taskLeaderOrgName.join(',');
		},
		// 取消回调事件
		treeCancel(e) {},
		// 显示树形选择器
		showTree() {
			this.$refs.tkitree._show();
		},

		cancel() {},
		confirm() {},
		show1() {
			this.show = true;
			this.model1.auditResult = 1;
			this.model1.targetType = this.model.targetType;
			this.model1.id = this.model.id;
			this.model1.targetId = this.model.targetId;
			this.model1.dcSupTaskInfo.id = this.model.taskId;
			this.model1.dcSupTaskInfo.createBy = this.model.auditorCode;
			this.$u.api.taskInfo.hs(this.model1).then(res => {
				if (res.result == 'true') {
					wx.reLaunch({
						url: '../../sys/home/index'
					});
				}
			});
		},
		show2() {
			this.model1.auditResult = 2;
			this.model1.targetType = this.model.targetType;
			this.model1.id = this.model.id;
			this.model1.targetId = this.model.targetId;
			this.model1.dcSupTaskInfo.id = this.model.taskId;
			this.model1.dcSupTaskInfo.createBy = this.model.auditorCode;
			this.$u.api.taskInfo.hs(this.model1).then(res => {
				if (res.result == 'true') {
					wx.reLaunch({
						url: '../../sys/home/index'
					});
				}
			});
		},
		changeLog(e) {},

		year(val) {
			this.model.taskYear = val;
		},
		TypeCode(val) {
			this.model.taskTypeCode = val[0];
			this.model.taskTypeName = val[1];
		},
		LeaderOrg(val) {
			this.model.taskLeaderOrg = val[0];
			this.model.taskLeaderOrgName = val[1];
		},
		selectChange2(val) {
			const newArray = [];
			val.forEach(item => {
				newArray.push({
					value: item
				});
			});

			this.model.taskLeader = val;
			const newArray1 = [];
			newArray.forEach((item, index) => {
				this.userSelectList.forEach((item1, index1) => {
					if (item.value == item1.value) {
						newArray1.push(item1.label);
					}
				});
			});
			this.model.taskLeaderName = newArray1.join(',');
		},
		Num(val) {
			this.model.msgNum = val;
		},

		submit() {
			this.model.messageNumber = this.model.msgNum + this.model.msgNum2;
			this.$refs.uForm.validate(valid => {
				if (valid) {
					this.$u.api.taskInfo.save(this.model).then(res => {
						uni.showModal({
							title: '提示',
							content: res.message,
							showCancel: false,
							success: function() {
								if (res.result == 'true') {
									uni.setStorageSync('refreshList', true);
									uni.navigateTo({
										url: './taskInfoList'
									});
								}
							}
						});
					});
				} else {
					this.$u.toast('您填写的信息有误，请根据提示修正。');
				}
			});
		},
		cancel() {
			uni.navigateBack();
		}
	}
};
</script>
<style lang="scss">
.shadow {
	position: fixed;
	top: 10%;
	width: 100%;
	height: 80%;
	z-index: 999;
	background-color: rgba(255, 255, 255, 0.1);
}
.shadow1 {
	position: fixed;
	top: 10%;
	width: 100%;
	height: 90%;
	z-index: 999;
	background-color: rgba(255, 255, 255, 0.1);
}
.taskInfoBox {
	margin-right: 24rpx;
	margin-left: 24rpx;
	& > view:last-child {
		border: none;
	}
}
.bk {
	word-break: break-all;
	text-align: justify !important;
}
</style>
